﻿namespace clowncar
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using Mono.Options;

    class Program
    {
        static int Main(string[] args)
        {
            var expand = false;

            var p = new OptionSet() {
                     { "e|expand",    "expand all .clown files to exe file", v =>  expand = v != null},
            };

            List<string> extra;
                try
                {
                    extra = p.Parse(args);
                }

                catch (OptionException e)
                {
                    Console.WriteLine(e.ToString());
                }

                if (expand)
                {
                    ExpandAllClowns();
                }

            return 0;
        }

        private static void ExpandAllClowns()
        {
            foreach (var f in Directory.GetFiles(".", "*.clown", SearchOption.AllDirectories))
            {

                var executable = "Placeholder.exe";
                var targetFolder = System.Reflection.Assembly.GetExecutingAssembly().Location;
                var exeFile = System.AppDomain.CurrentDomain.FriendlyName;
                var clownFile = Path.GetFileNameWithoutExtension(exeFile) + ".clown";

                var target = AssemblyUtils.ExtractResource(executable, targetFolder);
            }
        }
    }
}
